using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Portal.GUI.EditoralOffice.MainOffce.NewsEditModules.Video
{
    public partial class Video : Portal.API.Module
    {
        protected string videoUrl = "";
        protected string width = "";
        protected string height = "";
        protected string autoStart = "0";
        protected string playCount = "1";

        protected string flvWidth = "";
        protected string flvHeight = "";

        protected string modulePath = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)

                bindData();
                modulePath = "/GUI/" + this.ModuleType;
        }

        private void bindData()
        {
            LoadRuntimeSettings();

            string videoType = Convert.ToString(ReadRuntimeConfig(true, "VideoType"));
            if ("Flv".Equals(videoType, StringComparison.CurrentCultureIgnoreCase))
                displayFlv();
            else if ("Media".Equals(videoType, StringComparison.CurrentCultureIgnoreCase))
                displayMedia();

            videoUrl = Convert.ToString(ReadRuntimeConfig(true, "VideoUrl"));
            autoStart = (Convert.ToString(ReadRuntimeConfig(true, "AutoStart")) == "1" ? "true" : "false");  
        }

        private void displayFlv()
        {
            dvFlv.Visible = true;
            flvWidth = Convert.ToString(ReadRuntimeConfig(true, "Width"));
            flvHeight = Convert.ToString(ReadRuntimeConfig(true, "Height"));
        }

        private void displayMedia()
        {
            dvMedia.Visible = true;
            string _width = Convert.ToString(ReadRuntimeConfig(true, "Width"));
            if (!String.IsNullOrEmpty(_width))
                width = "width='" + _width + "'";
            string _height = Convert.ToString(ReadRuntimeConfig(true, "Height"));
            if (!String.IsNullOrEmpty(_height))
                height = "height='" + _height + "'";
            playCount = Convert.ToString(ReadRuntimeConfig(true, "PlayCount"));
        }
    }
}